package com.gjy.util.hutool;


public enum OperatorEnum {
    OPERATOR_EQUAL("0", "="),
    OPERATOR_NOT_EQUAL("1", "!="),
    OPERATOR_GREATER_THAN("2", ">"),
    OPERATOR_LESS_THAN("3", "<"),
    OPERATOR_LIKE("4", "LIKE"),
    OPERATOR_NOT_LIKE("5", "NOT LIKE"), OPERATOR_IN("6", "IN"),
    OPERATOR_NOT_IN("7", "NOT IN"),
    OPERATOR_IS_NULL("8", "IS NULL"),
    OPERATOR_IS_NOT_NULL("9", "IS NOT NULL");

    /**
     * 枚举状态编码
     */
    private String code;
    /**
     * 描述
     */
    private String desc;

    OperatorEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 通过外部传入的操作类型取枚举
     *
     * @param code 操作类型
     * @return 操作类型枚举
     */
    public static OperatorEnum getOperatorEnum(String code) {
        for (OperatorEnum enums : OperatorEnum.values()) {
            if (enums.getCode().equals(code)) {
                return enums;
            }
        }
        return null;
    }
}
